# json数据与python字典的相互转换

# import json
#
#
# # 链表中放着字典，将其转化为json
#
# data = [{"name":"张三","age":18},{"name":"李四","age":20}]
# json_str = json.dumps(data,ensure_ascii=False) # 加上 ensure_ascii=False 就可以看到中文了
# print(type(json_str))
# print(json_str)
#
#
# # 将字典转换为json
#
# d = {"name":"张三","addr":"台北"}
# json_str = json.dumps(d,ensure_ascii=False)
# print(json_str)
#
#
# # 将json字符串转换为python数据
#
# s = '[{"name": "张三", "age": 18}, {"name": "李四", "age": 20}]'
# l = json.loads(s)
# print(type(l))
# print(l)
#
#
# s = '{"name": "张三", "addr": "台北"}'
# l = json.loads(s)
# print(type(l))
# print(l)





